Don't let Google format reader crash on malformed route input.
authorrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 22 Dec 2014 19:32:31 +0000 (19:32 +0000)
committerrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 22 Dec 2014 19:32:31 +0000 (19:32 +0000)
gpsbabel/google.cc

index 01786de99bebd51ba883803991f818400e124f9e..86bdfc44c2757980e6338f58752ae6569b00651d 100644 (file)
@@ -103,10 +103,12 @@ void goog_segment(xg_string args, const QXmlStreamAttributes*)
 {
   Waypoint* wpt_tmp;
 
-  wpt_tmp = route_find_waypt_by_name(routehead[goog_segroute], goog_segname);
-  if (wpt_tmp) {
-    wpt_tmp->shortname = mkshort(desc_handle, args);
-    wpt_tmp->description = args;
+  if (routehead[goog_segroute]) {
+    wpt_tmp = route_find_waypt_by_name(routehead[goog_segroute], goog_segname);
+    if (wpt_tmp) {
+      wpt_tmp->shortname = mkshort(desc_handle, args);
+      wpt_tmp->description = args;
+    }
   }
 }
 
@@ -285,6 +287,7 @@ google_read(void)
   routehead = (route_head**)xmalloc(sizeof(route_head*));
   routecount = (int*)xmalloc(sizeof(int));
   goog_segroute = 0;
+  routehead[goog_segroute] = NULL;
 
   goog_read_file();